<template>
  <div>
    <h4 class="boardName" @click="gotoThat">
      加工信息
      <!-- <a-icon type="right" /> -->
    </h4>
    <div class=" setBox">
      <div class="tableBox">
        <a-table :pagination="false" :dataSource="AllProduce" :columns="columns" />
      </div>
    </div>
  </div>
</template>

<script>
function formatSeconds(value) {
  let result = parseInt(value);

  let y = Math.floor(result / 86400) < 10 ? '0' + Math.floor(result / 86400) : Math.floor(result / 86400);

  let h =
    Math.floor((result / 3600) % 24) < 10 ? '0' + Math.floor((result / 3600) % 24) : Math.floor((result / 3600) % 24);

  let m = Math.floor((result / 60) % 60) < 10 ? '0' + Math.floor((result / 60) % 60) : Math.floor((result / 60) % 60);

  let s = Math.floor(result % 60) < 10 ? '0' + Math.floor(result % 60) : Math.floor(result % 60);

  let res = '';
  if (y !== '00') res += `${y}天`;

  if (h !== '00') res += `${h}时`;

  if (m !== '00') res += `${m}分`;

  res += `${s}秒`;

  return res;
}

export default {
  props: {
    AllProduce: {
      type: Array,
    },
  },
  data() {
    return {
      columns: [
        {
          title: '加工机床',
          dataIndex: 'macNumb',
          key: 'macNumb',
        },
        {
          title: '程序名',
          dataIndex: 'produceName',
          key: 'produceName',
        },
        {
          title: '加工开始时间',
          dataIndex: 'startTime',
          key: 'startTime',
        },
        {
          title: '加工时间',
          dataIndex: 'produceTime',
          key: 'produceTime',
          customRender: (text, record, index) => {
            return formatSeconds(parseInt(text));
          },
        },
        {
          title: '当前计件数',
          dataIndex: 'partCount',
          key: 'partCount',
        },
      ],
    };
  },
  methods: {
    gotoThat() {},
  },
};
</script>

<style lang="less" scoped>
.setBox {
  margin-top: 2px;
  height: 422px;
  padding: 20px;
  overflow-y: scroll;
  width: 100%;
  background-color: #fff;
  border-radius: 6px;
}
.tableBox {
  border: 1px solid #e6e9ee;
  border-bottom: none;
}
/deep/.ant-table-thead {
  tr {
    th {
      padding: 6px 14px !important;
      color: #717d92 !important;
      background: #f4f8fb !important;
    }
  }
}
/deep/ .ant-table-tbody {
  tr {
    td {
      padding: 14px 14px !important;
      border-bottom: 1px solid #e6e9ee !important;
    }
  }
}
@import url('../../light.less');
@import url('../../style.less');
</style>
